package net.chathu.airgw.model 
{
	import net.chathu.airgw.Config;
	/**
	 * ...
	 * @author ze
	 */
	public class User implements IUser
	{
		
		public static const KEY_COLOR:String = "c";
		public static const KEY_DISTURB:String = "d";
		public static const KEY_SILENCE:String = "s";
		
		private var _id:int;
		public var regId:int;
		
		private var _registeredName:String;
		public var sex:int = 0;
		public var color:String;
		public var age:int;
		public var disturb:int;
		public var connectedTime:Date;
		public var type:int;
		
		//flood miatt nemitva van-e:
		public var silenced:Boolean;
		
		//chates nick, a registeredNamebol kepezzuk
		private var _name:String;
		
		public function User(id:int, regId:int, registeredName:String, sex:int, age:int, color:String, disturb:int, type:int, silenced:Boolean=false) 
		{
			this._id = id;
			this.regId = regId;
			this._registeredName = registeredName;
			this.sex = sex;
			this.age = age;
			this.color = color;
			this.disturb = disturb;
			this.type = type;
			this.silenced = silenced;
			connectedTime = new Date();
		}
		
		public function get userHost():String {
			if (Config.INCLUDE_AGE_AND_GENDER_IN_HOST)
			{
				return _name + "!~" + _name + "@" + shortExtraInfo + "." + regId + Config.IRC_USER_HOST;	
			} else {
				return _name + "!~" + _name + "@" + regId + Config.IRC_USER_HOST;
			}
			
			//include gender+age:
			
		}
		
		public function get shortExtraInfo():String {
			var ret:String;
			if ((type & 4) != 0)
			{
				ret = (type & 8) == 0 ? "F" : "N";
			} else {
				ret =  "T";
			}
			
			ret += age;
			
			return ret;
		}
		
		public function getGender():String {
			if ((type & 4) != 0)
			{
				return (type & 8) == 0 ? "Férfi" : "Nő";
			} else {
				return "Titkos";
			}
		}
		
		public function get id():* {
			return _id;
		}
		
		public function get originalName():String {
			return _registeredName;
		}
		
		
		public function get name():String {
			return _name;
		}
		
		public function set name(newName:String):void {
			_name = newName;
		}
		/*
		 *  public int getGender()
			{
				if((type & 4) != 0)
					return (type & 8) == 0 ? 1 : 2;
				else
					return 4;
			}
			
			public int HasPicture()
			{
				return (type & 0x30) >> 4;
			}

			public boolean isVIP()
			{
				return (type & 0x40) != 0;
			}
		 */
			
			
		
	}

}